package com.server.util;

/**
 * @author lulei
 * @date 2020年12月25日 10:39:52
 */
public class HttpProtocolUtil {
    /**
     * http200状态头信息
     * @return
     */
    public static String getHttpStatus200(Integer contentLegnth){
        String http200Str = "HTTP/1.1 200 OK \n"+
                            "Content-Type: text/html \n"+
                            "Content-Length: " + contentLegnth + " \n" +
                                "\r\n";
        return http200Str;
    }

    /**
     * http 404信息
     * @return
     */
    public static String getHttpHeader404() {
        String str404 = "<h1>404 not found</h1>";
        return "HTTP/1.1 404 NOT Found \n" +
                "Content-Type: text/html \n" +
                "Content-Length: " + str404.getBytes().length + " \n" +
                "\r\n" + str404;
    }
}
